package ace.module.account.sdk.core.feign.impl;

import ace.cmp.core.model.PageDto;
import ace.cmp.core.model.PageResultDto;
import ace.cmp.core.model.R;
import ace.cmp.openfeign.security.oauth2.core.config.FeignInternalServerOauth2SecurityConfig;
import ace.module.account.api.model.dto.IamAccountDetailDto;
import ace.module.account.api.model.input.IamAccountCommonInfoOutInput;
import ace.module.account.api.model.input.IamAccountModifyStatusInput;
import ace.module.account.api.model.input.IamAccountSearchInput;
import ace.module.account.api.model.input.IamAccountSearchOutInput;
import ace.module.account.api.model.input.IamAccountWithProfileSearchInput;
import ace.module.account.api.model.input.RegisterQuickByPhoneInput;
import ace.module.account.api.model.input.RegisterQuickByUsernameInput;
import ace.module.account.api.model.input.RegisterQuickByUsernameOutInput;
import ace.module.account.api.model.input.RegisterQuickByWxMiniAppIdAndOpenIdInput;
import ace.module.account.api.model.input.register.RegisterQuickByPhoneOutInput;
import ace.module.account.sdk.core.constant.SdkConstant;
import ace.module.account.sdk.core.feign.IamAccountFeignApi;
import ace.module.common.api.annotation.ApiRemoteProxyPriority;
import ace.module.common.api.model.input.PageInput;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 账户RPC API
 *
 * @author Caspar
 */
@FeignClient(
    name = "${spring.cloud.openfeign.client.config.iamAccountFeign.name:"
        + SdkConstant.FEIGN_SERVICE_NAME + "}",
    contextId = "iamAccountFeign",
    path = IamAccountFeign.PATH,
    configuration = FeignInternalServerOauth2SecurityConfig.class,
    primary = false
)
@ApiRemoteProxyPriority
public interface IamAccountFeign extends IamAccountFeignApi {

  String PATH = "${spring.cloud.openfeign.client.config.iamAccountFeign.path:/account/iam-account/rpc}";

  @PostMapping("/registerQuickByUsername")
  R<Long> registerQuickByUsername(@Valid @NotNull @RequestBody RegisterQuickByUsernameInput input);

  @PostMapping("/registerQuickByUsernameAndAppOutInfo")
  R<Long> registerQuickByUsernameAndAppOutInfo(
      @Valid @NotNull RegisterQuickByUsernameOutInput input);

  @PostMapping("/registerQuickByPhone")
  R<Long> registerQuickByPhone(@Valid @NotNull @RequestBody RegisterQuickByPhoneInput input);

  @PostMapping("/registerQuickByPhoneOutInput")
  R<Long> registerQuickByPhoneOutInput(
      @Valid @NotNull @RequestBody RegisterQuickByPhoneOutInput input);

  @PostMapping("/registerQuickByWxMiniAppIdAndOpenId")
  R<Long> registerQuickByWxMiniAppIdAndOpenId(
      @Valid @NotNull @RequestBody RegisterQuickByWxMiniAppIdAndOpenIdInput input);

  @GetMapping("/pageWithProfile")
  R<PageResultDto<IamAccountDetailDto>> pageWithProfile(
      @Valid @NotNull @SpringQueryMap IamAccountWithProfileSearchInput input,
      @Valid @NotNull @SpringQueryMap PageDto page);

  @PostMapping("/searchForDetail")
  R<PageResultDto<IamAccountDetailDto>> searchForDetail(
      @Valid @NotNull @RequestBody PageInput<IamAccountSearchInput> input);

  @PostMapping("/searchForDetailByOutInfo")
  R<PageResultDto<IamAccountDetailDto>> searchForDetailByOutInfo(
      @Valid @NotNull @RequestBody PageInput<IamAccountSearchOutInput> input);

  @PostMapping("/modifyCommonInfo")
  R<Void> modifyCommonInfo(@Valid @NotNull @RequestBody IamAccountCommonInfoOutInput input);

  @PostMapping("/modifyStatus")
  R<Void> modifyStatus(@Valid @NotNull @RequestBody IamAccountModifyStatusInput input);

}
